#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main(int argc,char*argv[])
{
	int     fd;
	char    buf[128];
	char     *ptr;
       	float    temp;

	fd=open("/sys/bus/w1/devices/28-0317320a8aff/w1_slave",O_RDONLY);

	memset(buf,0,sizeof(buf));//buf初始化
	read(fd,buf,sizeof(buf));
 	printf("buf:%s\n",buf);
         
        ptr=strstr(buf,"t=");
        if(!ptr)
	{
		printf("can not find t= string\n");
		return -1;
	
	}
        ptr+=2;
	temp=atof(ptr);
	printf("ptr: %s\n",ptr);
        printf("temp:%f\n",temp/1000);
	close(fd);

}
